<html>
<head><meta charset="utf-8"><title>Support indirects on const-prop · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html">Support indirects on const-prop</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="167033687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167033687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167033687">(May 31 2019 at 20:54)</a>:</h4>
<p>great</p>



<a name="167033696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167033696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167033696">(May 31 2019 at 20:54)</a>:</h4>
<p>ohh and I need a type for that constant</p>



<a name="167033715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167033715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167033715">(May 31 2019 at 20:55)</a>:</h4>
<p>should I take it from <code>Mplace.layout.ty</code>?</p>



<a name="167033723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167033723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167033723">(May 31 2019 at 20:55)</a>:</h4>
<p>Yeah, I believe that's already the <code>ty</code> you need</p>



<a name="167033986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167033986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167033986">(May 31 2019 at 20:59)</a>:</h4>
<p>ok i believe I'm almost there</p>



<a name="167034013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167034013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167034013">(May 31 2019 at 20:59)</a>:</h4>
<p>ok, to generate an <code>OpTy</code> I used <code>eval_operand</code>, but it needs a <code>SourceInfo</code></p>



<a name="167034407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167034407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167034407">(May 31 2019 at 21:05)</a>:</h4>
<p><code>replace_with_const</code> already takes a <code>Span</code>, so I'd just add it as another parameter</p>



<a name="167044485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167044485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167044485">(May 31 2019 at 23:58)</a>:</h4>
<p>But then I'll have to propagate that <code>SourceInfo</code> on every <code>replace_with_const</code> call</p>



<a name="167044968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167044968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167044968">(Jun 01 2019 at 00:10)</a>:</h4>
<p>I think you just need to change <code>replace-with_const</code>'s <code>Span</code> argument to be a <code>SourceLocation</code></p>



<a name="167044973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167044973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167044973">(Jun 01 2019 at 00:10)</a>:</h4>
<p>Then here at at the call site <a href="https://github.com/rust-lang/rust/blob/75f464481ed8c924086fc0b9a2d31841bbdbcabd/src/librustc_mir/transform/const_prop.rs#L658" target="_blank" title="https://github.com/rust-lang/rust/blob/75f464481ed8c924086fc0b9a2d31841bbdbcabd/src/librustc_mir/transform/const_prop.rs#L658">https://github.com/rust-lang/rust/blob/75f464481ed8c924086fc0b9a2d31841bbdbcabd/src/librustc_mir/transform/const_prop.rs#L658</a></p>



<a name="167044977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167044977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167044977">(Jun 01 2019 at 00:10)</a>:</h4>
<p>Just pass <code>statement.source_info</code></p>



<a name="167048494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167048494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167048494">(Jun 01 2019 at 01:43)</a>:</h4>
<p>ok will try</p>



<a name="167076264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167076264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167076264">(Jun 01 2019 at 15:12)</a>:</h4>
<p>I'm done with the changes :D, should I pr?</p>



<a name="167080557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167080557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167080557">(Jun 01 2019 at 16:59)</a>:</h4>
<p>Yeah, definitely!!</p>



<a name="167082153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167082153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167082153">(Jun 01 2019 at 17:37)</a>:</h4>
<p>a test failed D:</p>



<a name="167082164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167082164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167082164">(Jun 01 2019 at 17:37)</a>:</h4>
<p><code>run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs</code></p>



<a name="167082165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167082165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167082165">(Jun 01 2019 at 17:37)</a>:</h4>
<p>i dont think that's my fault</p>



<a name="167087703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167087703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167087703">(Jun 01 2019 at 20:10)</a>:</h4>
<p>Hmmm looks like it failed again</p>



<a name="167087709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167087709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167087709">(Jun 01 2019 at 20:10)</a>:</h4>
<p>I'm building locally...</p>



<a name="167088600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167088600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167088600">(Jun 01 2019 at 20:36)</a>:</h4>
<p>I don't understand why is this affecting trait solving</p>



<a name="167088814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167088814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167088814">(Jun 01 2019 at 20:43)</a>:</h4>
<p>/me waiting for llvm to finish building...</p>



<a name="167095668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167095668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167095668">(Jun 02 2019 at 00:04)</a>:</h4>
<p>Ok, I'm guessing this has something to do with the failing ptr being a null ptr.</p>



<a name="167095913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167095913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167095913">(Jun 02 2019 at 00:12)</a>:</h4>
<p>Nope, still failing...</p>



<a name="167096937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167096937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167096937">(Jun 02 2019 at 00:45)</a>:</h4>
<p>which failing ptr?</p>



<a name="167097611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167097611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167097611">(Jun 02 2019 at 01:07)</a>:</h4>
<div class="codehilite"><pre><span></span>TRACE 2019-06-02T00:45:18Z: rustc_mir::transform::const_prop: attepting to replace const &lt;&amp;usize as std::fmt::Debug&gt;::fmt as for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;usize, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt; (Pointer(ReifyFnPointer)) with OpTy { op: Indirect(MemPlace { ptr: AllocId(0).0x0, align: Align { pow2: 3 }, meta: None }), layout: TyLayout { ty: for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;usize, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt;, details: LayoutDetails { variants: Single { index: 0 }, fields: Union(0), abi: Scalar(Scalar { value: Pointer, valid_range: 1..=18446744073709551615 }), align: AbiAndPrefAlign { abi: Align { pow2: 3 }, pref: Align { pow2: 3 } }, size: Size { raw: 8 } } } }
TRACE 2019-06-02T00:45:18Z: rustc_mir::transform::const_prop: tag: ()
TRACE 2019-06-02T00:45:18Z: rustc_mir::transform::const_prop: Indirect: AllocId(0).0x0
TRACE 2019-06-02T00:45:18Z: rustc_mir::transform::const_prop: op: const Scalar(AllocId(0).0x0) : for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;usize, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt;
TRACE 2019-06-02T00:45:18Z: rustc_mir::transform::const_prop: opty: OpTy { op: Immediate(Scalar(AllocId(0).0x0)), layout: TyLayout { ty: for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;usize, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt;, details: LayoutDetails { variants: Single { index: 0 }, fields: Union(0), abi: Scalar(Scalar { value: Pointer, valid_range: 1..=18446744073709551615 }), align: AbiAndPrefAlign { abi: Align { pow2: 3 }, pref: Align { pow2: 3 } }, size: Size { raw: 8 } } } }
thread &#39;rustc&#39; panicked at &#39;called `Option::unwrap()` on a `None` value&#39;, src/libcore/option.rs:347:21
</pre></div>



<a name="167098589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167098589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167098589">(Jun 02 2019 at 01:36)</a>:</h4>
<p>where does this unwrap comes from? I though that const-prop just stops when it cannot propagate</p>



<a name="167098727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167098727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167098727">(Jun 02 2019 at 01:41)</a>:</h4>
<p>Yeah, I'm not sure. I can't seem to get a backtrace on my mac</p>



<a name="167100149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167100149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167100149">(Jun 02 2019 at 02:22)</a>:</h4>
<p>Ok, it looks like what happened is that your changes allowed more const evaluation to happen elsewhere and that's what's causing the ICE</p>



<a name="167100153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167100153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167100153">(Jun 02 2019 at 02:22)</a>:</h4>
<p>Specifically, the test ICEs because it tries to const eval this:</p>
<div class="codehilite"><pre><span></span>_42 = const &lt;&amp;usize as std::fmt::Debug&gt;::fmt as for&lt;&#39;r, &#39;s, &#39;t0&gt; fn(&amp;&#39;r &amp;usize, &amp;&#39;s mut std::fmt::Formatter&lt;&#39;t0&gt;) -&gt; std::result::Result&lt;(), std::fmt::Error&gt; (Pointer(ReifyFnPointer))
</pre></div>


<p>and that doesn't seem to work at all</p>



<a name="167100210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167100210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167100210">(Jun 02 2019 at 02:24)</a>:</h4>
<p>So probably somewhere around here <a href="https://github.com/rust-lang/rust/blob/46e0f2721a8f8fe84588e081c96ace5aecf25a32/src/librustc_mir/transform/const_prop.rs#L372" target="_blank" title="https://github.com/rust-lang/rust/blob/46e0f2721a8f8fe84588e081c96ace5aecf25a32/src/librustc_mir/transform/const_prop.rs#L372">https://github.com/rust-lang/rust/blob/46e0f2721a8f8fe84588e081c96ace5aecf25a32/src/librustc_mir/transform/const_prop.rs#L372</a></p>



<a name="167100222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167100222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167100222">(Jun 02 2019 at 02:25)</a>:</h4>
<p>We need to check if <code>kind</code> is a <code>CastKind::Pointer(_)</code> and <code>return None</code> in that case.</p>



<a name="167101026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167101026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167101026">(Jun 02 2019 at 02:49)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> might have a better suggestion</p>



<a name="167104803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167104803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167104803">(Jun 02 2019 at 04:44)</a>:</h4>
<p>I did the changes and I'm testing now</p>



<a name="167109328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167109328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167109328">(Jun 02 2019 at 07:10)</a>:</h4>
<p>It failed again, maybe this is propagating elsewhere?</p>



<a name="167129246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167129246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167129246">(Jun 02 2019 at 16:49)</a>:</h4>
<p>The ui tests are all passing now so that's good!</p>



<a name="167129256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167129256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167129256">(Jun 02 2019 at 16:49)</a>:</h4>
<p>There's 4 failing MIR optimization tests. I think they're all ICEs.</p>



<a name="167129257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167129257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167129257">(Jun 02 2019 at 16:49)</a>:</h4>
<p>I've got a fix for one and I'm investigating the others</p>



<a name="167139021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167139021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167139021">(Jun 02 2019 at 21:18)</a>:</h4>
<p><span class="user-mention" data-user-id="132916">@Christian Poveda</span> I pushed some fixes into your branch per <span class="user-mention" data-user-id="124288">@oli</span>'s comments on GitHub</p>



<a name="167145691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167145691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167145691">(Jun 03 2019 at 00:25)</a>:</h4>
<p>Thank you!</p>



<a name="167180905"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167180905" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167180905">(Jun 03 2019 at 11:49)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> you around?</p>



<a name="167180912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167180912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167180912">(Jun 03 2019 at 11:49)</a>:</h4>
<p>jop</p>



<a name="167180915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167180915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167180915">(Jun 03 2019 at 11:49)</a>:</h4>
<p>Got a minute to chat about this pr?</p>



<a name="167180917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167180917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167180917">(Jun 03 2019 at 11:49)</a>:</h4>
<p>yes</p>



<a name="167180970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167180970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167180970">(Jun 03 2019 at 11:50)</a>:</h4>
<p>So your comment <a href="https://github.com/rust-lang/rust/pull/61437#issuecomment-498165707" target="_blank" title="https://github.com/rust-lang/rust/pull/61437#issuecomment-498165707">here</a> is basically how I understand this to work.</p>



<a name="167180986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167180986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167180986">(Jun 03 2019 at 11:50)</a>:</h4>
<p>So I guess I'm either not understanding something (probably that) or I'm confused why you don't think this should work.</p>



<a name="167181009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181009">(Jun 03 2019 at 11:51)</a>:</h4>
<p>Do steps 1-5 make sense to you?</p>



<a name="167181025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181025">(Jun 03 2019 at 11:51)</a>:</h4>
<p>4 and 5  don't make sense to me considering 1-3 happened</p>



<a name="167181033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181033">(Jun 03 2019 at 11:51)</a>:</h4>
<p>ok</p>



<a name="167181099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181099">(Jun 03 2019 at 11:52)</a>:</h4>
<p>so basically what I thought was the situation is that <code>Operand::Immediate</code> refers to the memory, e.g. where the <code>5</code> in <code>5 as u8</code> is stored</p>



<a name="167181110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181110">(Jun 03 2019 at 11:52)</a>:</h4>
<p>so step 2 gives you an <code>Immediate::Scalar(5)</code></p>



<a name="167181115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181115">(Jun 03 2019 at 11:53)</a>:</h4>
<p>and then we turn that <code>5</code> into a pointer?</p>



<a name="167181126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181126">(Jun 03 2019 at 11:53)</a>:</h4>
<p>and create a <code>ByRef</code> whose location is <code>5</code>?</p>



<a name="167181127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181127">(Jun 03 2019 at 11:53)</a>:</h4>
<p>Hmm... that not how I understand it</p>



<a name="167181190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181190">(Jun 03 2019 at 11:54)</a>:</h4>
<blockquote>
<p>so basically what I thought was the situation is that <code>Operand::Immediate</code> refers to the memory, e.g. where the <code>5</code> in <code>5 as u8</code> is stored</p>
</blockquote>
<p>Wait do you mean Immediate or Indirect?</p>



<a name="167181220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181220">(Jun 03 2019 at 11:54)</a>:</h4>
<p>Immediate is just a Scalar. I don't think there's a memory location associated with that.</p>



<a name="167181223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181223">(Jun 03 2019 at 11:54)</a>:</h4>
<p>(Right?)</p>



<a name="167181244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181244">(Jun 03 2019 at 11:55)</a>:</h4>
<p>oh, sorry, I meant <code>Indirect</code></p>



<a name="167181248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181248">(Jun 03 2019 at 11:55)</a>:</h4>
<p>Ok.</p>



<a name="167181256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181256">(Jun 03 2019 at 11:55)</a>:</h4>
<p>yea, <code>Operand::Immediate</code> just contains an <code>Immediate</code>, which can only be <code>Scalar</code> or <code>ScalarPair</code></p>



<a name="167181324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181324">(Jun 03 2019 at 11:56)</a>:</h4>
<p>So, as I understand it, <code>5</code> is a <code>Immediate(Scalar(5))</code>. <code>5 as u8</code> runs the code which handles <code>Rvalue::Cast</code>. That code will allocate space for the result so <code>5 as u8</code> becomes an <del><code>Immediate(Pointer(xxxx))</code></del> <code>Indirect</code> which points to that allocated memory.</p>



<a name="167181353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181353">(Jun 03 2019 at 11:57)</a>:</h4>
<p>So prior to this change, we could handle <code>5 as u8</code> but because the result became an <del><code>Immediate</code></del>, <code>Indirect</code> we couldn't go any further. Thus, we couldn't handle <code>(5 as u8) + 1</code></p>



<a name="167181381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181381">(Jun 03 2019 at 11:57)</a>:</h4>
<p>Now we can and we get the correct <code>6u8</code>.</p>



<a name="167181576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181576">(Jun 03 2019 at 12:00)</a>:</h4>
<p>So going back to your comment, 1 matches my understanding.</p>



<a name="167181597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181597">(Jun 03 2019 at 12:01)</a>:</h4>
<p>In 2, the <code>Immediate</code> is just the pointer to the allocated memory, not the value itself.</p>



<a name="167181603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181603">(Jun 03 2019 at 12:01)</a>:</h4>
<p>3 matches</p>



<a name="167181612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181612">(Jun 03 2019 at 12:01)</a>:</h4>
<p>wait</p>



<a name="167181617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181617">(Jun 03 2019 at 12:01)</a>:</h4>
<p>In 4, the value is a pointer, so that always(?) works</p>



<a name="167181618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181618">(Jun 03 2019 at 12:01)</a>:</h4>
<p>are we confusing <code>Immediate</code> and <code>Indirect</code> again?</p>



<a name="167181663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181663">(Jun 03 2019 at 12:02)</a>:</h4>
<p>hmmm</p>



<a name="167181666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181666">(Jun 03 2019 at 12:02)</a>:</h4>
<p>Yes</p>



<a name="167181683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181683">(Jun 03 2019 at 12:02)</a>:</h4>
<blockquote>
<p>So prior to this change, we could handle <code>5 as u8</code> but because the result became an <code>Immediate</code>, we couldn't go any further. Thus, we couldn't handle <code>(5 as u8) + 1</code></p>
</blockquote>
<p>should be:</p>
<p>So prior to this change, we could handle <code>5 as u8</code> but because the result became an <code>Indirect</code>, we couldn't go any further. Thus, we couldn't handle <code>(5 as u8) + 1</code></p>



<a name="167181720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181720">(Jun 03 2019 at 12:03)</a>:</h4>
<blockquote>
<p>So, as I understand it, <code>5</code> is a <code>Immediate(Scalar(5))</code>. <code>5 as u8</code> runs the code which handles <code>Rvalue::Cast</code>. That code will allocate space for the result so <code>5 as u8</code> becomes an <code>Immediate(Pointer(xxxx))</code> which points to that allocated memory.</p>
</blockquote>
<p>Also: <code>5 as u8</code> becomes <code>Indirect(MPlace { ptr: Pointer(xxx) })</code></p>



<a name="167181734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181734">(Jun 03 2019 at 12:03)</a>:</h4>
<p>Yes</p>



<a name="167181792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181792">(Jun 03 2019 at 12:04)</a>:</h4>
<p>So in step 2, when calling <code>read_immediate</code>, we end up with an <code>Immediate::Scalar(5)</code></p>



<a name="167181797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181797">(Jun 03 2019 at 12:04)</a>:</h4>
<p>(I think?)</p>



<a name="167181847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181847">(Jun 03 2019 at 12:05)</a>:</h4>
<p>The source of <code>read_immediate</code> is <a href="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L271" target="_blank" title="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L271">https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L271</a></p>



<a name="167181932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181932">(Jun 03 2019 at 12:06)</a>:</h4>
<p>and <code>try_as_mplace</code> gives us an <code>MPlace</code> if we have <code>Operand::Indirect</code>: <a href="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/place.rs#L235" target="_blank" title="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/place.rs#L235">https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/place.rs#L235</a></p>



<a name="167181943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181943">(Jun 03 2019 at 12:07)</a>:</h4>
<p>I thought we ended up with a <code>Immediate::Scalar(ptr)</code> or whatever. Basically the equivalent of <code>int* x = (int*)malloc(...);</code> and then the raw address <code>x</code>.</p>



<a name="167181966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167181966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167181966">(Jun 03 2019 at 12:07)</a>:</h4>
<p>I'm fairly certain we don't: <a href="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L240" target="_blank" title="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L240">https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L240</a> but I have messed up indirect/direct before</p>



<a name="167182036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182036">(Jun 03 2019 at 12:08)</a>:</h4>
<p>it's more of a <code>int&amp; x = y;</code> where the implementation chooses to represent c++ references as pointers and autoderef for the user</p>



<a name="167182088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182088">(Jun 03 2019 at 12:09)</a>:</h4>
<p>I believe you are correct</p>



<a name="167182175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182175">(Jun 03 2019 at 12:10)</a>:</h4>
<p>So then 4 &amp; 5 shouldn't work at all</p>



<a name="167182177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182177">(Jun 03 2019 at 12:10)</a>:</h4>
<p>But they are...</p>



<a name="167182235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182235">(Jun 03 2019 at 12:11)</a>:</h4>
<p>yea, that's what baffles me :D</p>



<a name="167182349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182349">(Jun 03 2019 at 12:12)</a>:</h4>
<p>I'm adding some tracing code so I can see exactly what all these values are</p>



<a name="167182408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182408">(Jun 03 2019 at 12:13)</a>:</h4>
<p>The issue has got be with our understanding of 2</p>



<a name="167182462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182462">(Jun 03 2019 at 12:14)</a>:</h4>
<p>If it works they way we're saying it does, then 4 &amp; 5 don't make any sense at all</p>



<a name="167182478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182478">(Jun 03 2019 at 12:14)</a>:</h4>
<p>yea, I'm reviewing 4 and 5 rn</p>



<a name="167182482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182482">(Jun 03 2019 at 12:14)</a>:</h4>
<p>and yet they work. So they have to be doing something correctly</p>



<a name="167182484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182484">(Jun 03 2019 at 12:14)</a>:</h4>
<p>maybe we missed something there</p>



<a name="167182544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182544">(Jun 03 2019 at 12:15)</a>:</h4>
<p>OR: we are somehow reading from <code>ByRef</code> wrongly elsewhere</p>



<a name="167182647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182647">(Jun 03 2019 at 12:17)</a>:</h4>
<p>But <code>operand_from_ref</code> does this:</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">imm_ty</span><span class="p">.</span><span class="n">to_scalar_ptr</span><span class="p">().</span><span class="n">ok</span><span class="p">()</span><span class="o">?</span><span class="p">.</span><span class="n">to_ptr</span><span class="p">().</span><span class="n">ok</span><span class="p">()</span><span class="o">?</span><span class="p">;</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">allocation</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">ecx</span><span class="p">.</span><span class="n">memory</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="n">ptr</span><span class="p">.</span><span class="n">alloc_id</span><span class="p">).</span><span class="n">ok</span><span class="p">()</span><span class="o">?</span><span class="p">.</span><span class="n">clone</span><span class="p">();</span><span class="w"></span>
</pre></div>



<a name="167182658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182658">(Jun 03 2019 at 12:17)</a>:</h4>
<p>maybe that code never goes beyond the second <code>?</code></p>



<a name="167182661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182661">(Jun 03 2019 at 12:17)</a>:</h4>
<p><em>How is that working</em>?</p>



<a name="167182665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182665">(Jun 03 2019 at 12:17)</a>:</h4>
<p>and your test already works :D</p>



<a name="167182739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182739">(Jun 03 2019 at 12:18)</a>:</h4>
<p>If it doesn't, then we don't do this <a href="https://github.com/rust-lang/rust/pull/61437/files#diff-9e103702275cbef342c2decd3395bf3bR599" target="_blank" title="https://github.com/rust-lang/rust/pull/61437/files#diff-9e103702275cbef342c2decd3395bf3bR599">https://github.com/rust-lang/rust/pull/61437/files#diff-9e103702275cbef342c2decd3395bf3bR599</a></p>



<a name="167182790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182790">(Jun 03 2019 at 12:18)</a>:</h4>
<p>yea, but the test you wrote may just never excercise <code>Indirect</code></p>



<a name="167182856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182856">(Jun 03 2019 at 12:19)</a>:</h4>
<div class="codehilite"><pre><span></span>TRACE 2019-06-03T12:18:57Z: rustc_mir::transform::const_prop: handling indirect
TRACE 2019-06-03T12:18:57Z: rustc_mir::transform::const_prop: reading value: OpTy { op: Indirect(MemPlace { ptr: AllocId(2).0x0, align: Align { pow2: 0 }, meta: None }), layout: TyLayout { ty: u8, details: LayoutDetails { variants: Single { index: 0 }, fields: Union(0), abi: Scalar(Scalar { value: Int(I8, false), valid_range: 0..=255 }), align: AbiAndPrefAlign { abi: Align { pow2: 0 }, pref: Align { pow2: 0 } }, size: Size { raw: 1 } } } }
TRACE 2019-06-03T12:18:57Z: rustc_mir::transform::const_prop: imm: Some(ImmTy { imm: Scalar(0x02), layout: TyLayout { ty: u8, details: LayoutDetails { variants: Single { index: 0 }, fields: Union(0), abi: Scalar(Scalar { value: Int(I8, false), valid_range: 0..=255 }), align: AbiAndPrefAlign { abi: Align { pow2: 0 }, pref: Align { pow2: 0 } }, size: Size { raw: 1 } } } })
TRACE 2019-06-03T12:18:57Z: rustc_mir::transform::const_prop: imm_ty: ImmTy { imm: Scalar(0x02), layout: TyLayout { ty: u8, details: LayoutDetails { variants: Single { index: 0 }, fields: Union(0), abi: Scalar(Scalar { value: Int(I8, false), valid_range: 0..=255 }), align: AbiAndPrefAlign { abi: Align { pow2: 0 }, pref: Align { pow2: 0 } }, size: Size { raw: 1 } } } }
</pre></div>



<a name="167182877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182877">(Jun 03 2019 at 12:19)</a>:</h4>
<p>right, but what I mean is that the binop also works: <a href="https://github.com/rust-lang/rust/blob/6901ad4c424dc515cfa0101591564ce14f61788c/src/librustc_mir/transform/const_prop.rs#L478" target="_blank" title="https://github.com/rust-lang/rust/blob/6901ad4c424dc515cfa0101591564ce14f61788c/src/librustc_mir/transform/const_prop.rs#L478">https://github.com/rust-lang/rust/blob/6901ad4c424dc515cfa0101591564ce14f61788c/src/librustc_mir/transform/const_prop.rs#L478</a></p>



<a name="167182881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182881">(Jun 03 2019 at 12:19)</a>:</h4>
<blockquote>
<p>maybe that code never goes beyond the second <code>?</code></p>
</blockquote>
<p>I think you hit the nail on the head here</p>



<a name="167182927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182927">(Jun 03 2019 at 12:20)</a>:</h4>
<p>because it does <code>read_immediate</code></p>



<a name="167182954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182954">(Jun 03 2019 at 12:20)</a>:</h4>
<p>That's where the logging I added stops</p>



<a name="167182981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182981">(Jun 03 2019 at 12:20)</a>:</h4>
<p>still weird that the test shows what it does</p>



<a name="167182989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182989">(Jun 03 2019 at 12:20)</a>:</h4>
<p>Yes, that already worked</p>



<a name="167182994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167182994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167182994">(Jun 03 2019 at 12:20)</a>:</h4>
<p>You were right</p>



<a name="167183006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183006">(Jun 03 2019 at 12:21)</a>:</h4>
<p>So that's why the test is working</p>



<a name="167183011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183011">(Jun 03 2019 at 12:21)</a>:</h4>
<p>oh</p>



<a name="167183013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183013">(Jun 03 2019 at 12:21)</a>:</h4>
<p>wait</p>



<a name="167183021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183021">(Jun 03 2019 at 12:21)</a>:</h4>
<p>the test is indeed showing it: <code>_2 = const 2u32 as u8 (Misc);</code></p>



<a name="167183033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183033">(Jun 03 2019 at 12:21)</a>:</h4>
<p>after optimizations that cast should be gone</p>



<a name="167183040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183040">(Jun 03 2019 at 12:21)</a>:</h4>
<p>Yeah</p>



<a name="167183050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183050">(Jun 03 2019 at 12:21)</a>:</h4>
<p><span aria-label="face palm" class="emoji emoji-1f926" role="img" title="face palm">:face_palm:</span></p>



<a name="167183137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183137">(Jun 03 2019 at 12:22)</a>:</h4>
<p>So <code>read_immediate()</code> is doing the deref for us</p>



<a name="167183144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183144">(Jun 03 2019 at 12:22)</a>:</h4>
<p>well "deref"</p>



<a name="167183154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183154">(Jun 03 2019 at 12:22)</a>:</h4>
<p>heh yeah</p>



<a name="167183161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183161">(Jun 03 2019 at 12:22)</a>:</h4>
<p>not semantically, but implementation wise, yes</p>



<a name="167183196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183196">(Jun 03 2019 at 12:23)</a>:</h4>
<p>ok, so since <code>read_immediate</code> "just works", I suggest to throw away all changes of the PR and just do <code>try_read_immediate</code> instead of matching on the <code>Operand</code>, that way we end up with an <code>ImmTy</code> that we can match on and get either a scalar or a scalar pair out of</p>



<a name="167183334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183334">(Jun 03 2019 at 12:24)</a>:</h4>
<p>or, if we want to const propagate even non-immediates, we go by the <code>ByRef</code> route</p>



<a name="167183381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183381">(Jun 03 2019 at 12:25)</a>:</h4>
<p>but as already mentioned on the PR, that may overeagerly intern allocations</p>



<a name="167183404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183404">(Jun 03 2019 at 12:25)</a>:</h4>
<p>so that should probably only be done at higher optimizations levels</p>



<a name="167183419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183419">(Jun 03 2019 at 12:25)</a>:</h4>
<p>We still need to handle <code>Immediate</code> ourselves right? Since <code>try_read_immediate</code> does a <code>try_as_mplace</code> which fails if we're an <code>Immediate</code></p>



<a name="167183538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183538">(Jun 03 2019 at 12:26)</a>:</h4>
<p>it gives you the <code>Immediate</code> if <code>try_as_mplace</code> returns <code>Err</code></p>



<a name="167183547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183547">(Jun 03 2019 at 12:27)</a>:</h4>
<p>all very confusing :D I agree</p>



<a name="167183560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183560">(Jun 03 2019 at 12:27)</a>:</h4>
<p>failure is success</p>



<a name="167183577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183577">(Jun 03 2019 at 12:27)</a>:</h4>
<p>Oh <a href="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L283" target="_blank" title="https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L283">https://github.com/rust-lang/rust/blob/627486af15d222bcba336b12ea92a05237cc9ab1/src/librustc_mir/interpret/operand.rs#L283</a></p>



<a name="167183588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183588">(Jun 03 2019 at 12:27)</a>:</h4>
<p>Ok, yeah we can just call that</p>



<a name="167183729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167183729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167183729">(Jun 03 2019 at 12:29)</a>:</h4>
<p>Thanks! I think <span class="user-mention" data-user-id="132916">@Christian Poveda</span> and I can take it from there</p>



<a name="167190471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167190471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167190471">(Jun 03 2019 at 13:40)</a>:</h4>
<p>Why all the fun happens when I'm sleeping?</p>



<a name="167191029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167191029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167191029">(Jun 03 2019 at 13:46)</a>:</h4>
<p>So, then we just need to take the <code>OpTy</code> and use <code>try_read_immediate</code>?</p>



<a name="167191154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167191154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167191154">(Jun 03 2019 at 13:47)</a>:</h4>
<p>depends... just emitting a <code>ByRef</code> constant for the <code>Indirect</code> is more general</p>



<a name="167191213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167191213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167191213">(Jun 03 2019 at 13:48)</a>:</h4>
<p>but requires more memory</p>



<a name="167191245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167191245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167191245">(Jun 03 2019 at 13:48)</a>:</h4>
<p>I think you don't actually need to change anything here, because propagation works even over "unpropagated" locals</p>



<a name="167191295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167191295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167191295">(Jun 03 2019 at 13:49)</a>:</h4>
<p>it's just a question of whether the <code>Indirect</code> should show up in the MIR</p>



<a name="167191311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167191311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167191311">(Jun 03 2019 at 13:49)</a>:</h4>
<p>the propagation happens irrelevant of whether you modify the MIR</p>



<a name="167191952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167191952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167191952">(Jun 03 2019 at 13:56)</a>:</h4>
<p>Let me see if I understand correctly, the thing is that in fact evaluating <code>Indirect</code>s would use too much memory, is that right?</p>



<a name="167193062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167193062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167193062">(Jun 03 2019 at 14:08)</a>:</h4>
<p>evaluating e.g. an <code>as</code> cast will allocate additional memory for the duration of the const prop pass. That memory will get cleared afterwards. If you create a <code>ty::Const</code> though, the memory will need to get interned first (which you did), and then it will stay around for the entire compilation.</p>



<a name="167193156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167193156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167193156">(Jun 03 2019 at 14:09)</a>:</h4>
<p>if we are never using that value though (as we don't in the given example, because the cast's result is dead code after the propagation), then that would just be a waste of memory</p>



<a name="167193204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167193204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167193204">(Jun 03 2019 at 14:09)</a>:</h4>
<p>If the value didn't get promoted or has more use sites later, then that memory usage is ok</p>



<a name="167193287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167193287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167193287">(Jun 03 2019 at 14:10)</a>:</h4>
<p>if the value itself is a scalar, then we should not be using <code>ByRef</code> anyway, so... we'd need to do the <code>try_read_immediate</code> optimization</p>



<a name="167193332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167193332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167193332">(Jun 03 2019 at 14:11)</a>:</h4>
<p>So... I guess do <code>try_read_immediate</code> for now and leave a fixme to also handle the situation where <code>try_read_immediate</code> fails</p>



<a name="167193476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167193476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167193476">(Jun 03 2019 at 14:12)</a>:</h4>
<blockquote>
<p>evaluating e.g. an <code>as</code> cast will allocate additional memory for the duration of the const prop pass. That memory will get cleared afterwards. If you create a <code>ty::Const</code> though, the memory will need to get interned first (which you did), and then it will stay around for the entire compilation.</p>
</blockquote>
<p>Ohh ok I understand</p>



<a name="167194128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167194128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167194128">(Jun 03 2019 at 14:18)</a>:</h4>
<blockquote>
<p>So... I guess do <code>try_read_immediate</code> for now and leave a fixme to also handle the situation where <code>try_read_immediate</code> fails</p>
</blockquote>
<p>here <a href="https://github.com/rust-lang/rust/pull/61437/files#diff-9e103702275cbef342c2decd3395bf3bR594" target="_blank" title="https://github.com/rust-lang/rust/pull/61437/files#diff-9e103702275cbef342c2decd3395bf3bR594">https://github.com/rust-lang/rust/pull/61437/files#diff-9e103702275cbef342c2decd3395bf3bR594</a>, right?</p>



<a name="167194555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167194555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167194555">(Jun 03 2019 at 14:22)</a>:</h4>
<p>No, get rid of the entire <code>match value</code> and do <code>let imm = ....try_immediate(value).ok()??;</code> or sth and just have the <code>match imm</code> that is currently in the <code>Operand::Immediate</code> arm</p>



<a name="167195171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167195171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167195171">(Jun 03 2019 at 14:27)</a>:</h4>
<p>so something like this: </p>
<div class="codehilite"><pre><span></span><span class="w">                </span><span class="c1">// FIXME&gt; figure out what tho do when try_read_immediate fails</span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">imm</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">use_ecx</span><span class="p">(</span><span class="n">source_info</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">this</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">this</span><span class="p">.</span><span class="n">ecx</span><span class="p">.</span><span class="n">try_read_immediate</span><span class="p">(</span><span class="n">value</span><span class="p">)</span><span class="w"></span>
<span class="w">                </span><span class="p">});</span><span class="w"></span>

<span class="w">                </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">imm</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">imm</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">operand_from_ref</span><span class="p">(</span><span class="n">imm</span><span class="p">,</span><span class="w"> </span><span class="n">source_info</span><span class="p">.</span><span class="n">span</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="o">*</span><span class="n">rval</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Rvalue</span>::<span class="n">Use</span><span class="p">(</span><span class="n">op</span><span class="p">);</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="167195308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167195308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167195308">(Jun 03 2019 at 14:28)</a>:</h4>
<p>no, I mean, don't have an <code>match value</code>  (and thus <code>Operand::Indirect</code>) arm at all</p>



<a name="167195335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167195335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167195335">(Jun 03 2019 at 14:28)</a>:</h4>
<p>yes yes</p>



<a name="167195380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167195380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167195380">(Jun 03 2019 at 14:29)</a>:</h4>
<p>/me is confused</p>



<a name="167195402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167195402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167195402">(Jun 03 2019 at 14:29)</a>:</h4>
<p>me too, me too</p>



<a name="167195405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167195405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167195405">(Jun 03 2019 at 14:29)</a>:</h4>
<p>hahaha</p>



<a name="167196164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167196164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167196164">(Jun 03 2019 at 14:35)</a>:</h4>
<blockquote>
<p>no, I mean, don't have an <code>match value</code>  (and thus <code>Operand::Indirect</code>) arm at all</p>
</blockquote>
<p>that code would be the replacement for the whole thing</p>



<a name="167196280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167196280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167196280">(Jun 03 2019 at 14:36)</a>:</h4>
<p>ah, no don't use <code>operand_from_ref</code>, use the existing <code>match</code> that emits <code>Scalar</code> and <code>ScalarPair</code></p>



<a name="167196367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167196367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167196367">(Jun 03 2019 at 14:37)</a>:</h4>
<blockquote>
<p>No, get rid of the entire <code>match value</code> and do <code>let imm = ....try_immediate(value).ok()??;</code> or sth and just have the <code>match imm</code> that is currently in the <code>Operand::Immediate</code> arm</p>
</blockquote>
<p>this is basically taking the <code>Operand::Immediate</code> arm and deleting the  <code>match value</code></p>



<a name="167196419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167196419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167196419">(Jun 03 2019 at 14:37)</a>:</h4>
<p>but doing <code>try_read_immediate</code> instead of <code>read_immediate</code></p>



<a name="167196544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167196544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167196544">(Jun 03 2019 at 14:38)</a>:</h4>
<p>ohhhhhhhh</p>



<a name="167196549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167196549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167196549">(Jun 03 2019 at 14:38)</a>:</h4>
<p>i get it, i feel dumb</p>



<a name="167197380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167197380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167197380">(Jun 03 2019 at 14:47)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="w">        </span><span class="c1">// FIXME&gt; figure out what tho do when try_read_immediate fails</span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">imm</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">use_ecx</span><span class="p">(</span><span class="n">source_info</span><span class="p">,</span><span class="w"> </span><span class="o">|</span><span class="n">this</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">this</span><span class="p">.</span><span class="n">ecx</span><span class="p">.</span><span class="n">try_read_immediate</span><span class="p">(</span><span class="n">value</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">});</span><span class="w"></span>

<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">imm</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">imm</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">match</span><span class="w"> </span><span class="n">imm</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="n">interpret</span>::<span class="n">Immediate</span>::<span class="n">Scalar</span><span class="p">(</span><span class="n">ScalarMaybeUndef</span>::<span class="n">Scalar</span><span class="p">(</span><span class="n">scalar</span><span class="p">))</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="o">*</span><span class="n">rval</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Rvalue</span>::<span class="n">Use</span><span class="p">(</span><span class="w"></span>
<span class="w">                        </span><span class="bp">self</span><span class="p">.</span><span class="n">operand_from_scalar</span><span class="p">(</span><span class="n">scalar</span><span class="p">,</span><span class="w"> </span><span class="n">value</span><span class="p">.</span><span class="n">layout</span><span class="p">.</span><span class="n">ty</span><span class="p">,</span><span class="w"> </span><span class="n">source_info</span><span class="p">.</span><span class="n">span</span><span class="p">));</span><span class="w"></span>
<span class="w">                </span><span class="p">},</span><span class="w"></span>
<span class="w">                </span><span class="n">Immediate</span>::<span class="n">ScalarPair</span><span class="p">(</span><span class="w"></span>
<span class="w">                    </span><span class="n">ScalarMaybeUndef</span>::<span class="n">Scalar</span><span class="p">(</span><span class="n">one</span><span class="p">),</span><span class="w"></span>
<span class="w">                    </span><span class="n">ScalarMaybeUndef</span>::<span class="n">Scalar</span><span class="p">(</span><span class="n">two</span><span class="p">)</span><span class="w"></span>
<span class="w">                    </span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="n">ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="n">value</span><span class="p">.</span><span class="n">layout</span><span class="p">.</span><span class="n">ty</span><span class="p">.</span><span class="n">sty</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="n">ty</span>::<span class="n">Tuple</span><span class="p">(</span><span class="n">substs</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ty</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="o">*</span><span class="n">rval</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Rvalue</span>::<span class="n">Aggregate</span><span class="p">(</span><span class="w"></span>
<span class="w">                            </span><span class="nb">Box</span>::<span class="n">new</span><span class="p">(</span><span class="n">AggregateKind</span>::<span class="n">Tuple</span><span class="p">),</span><span class="w"></span>
<span class="w">                            </span><span class="n">vec</span><span class="o">!</span><span class="p">[</span><span class="w"></span>
<span class="w">                            </span><span class="bp">self</span><span class="p">.</span><span class="n">operand_from_scalar</span><span class="p">(</span><span class="w"></span>
<span class="w">                                </span><span class="n">one</span><span class="p">,</span><span class="w"> </span><span class="n">substs</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="n">expect_ty</span><span class="p">(),</span><span class="w"> </span><span class="n">source_info</span><span class="p">.</span><span class="n">span</span><span class="w"></span>
<span class="w">                                </span><span class="p">),</span><span class="w"></span>
<span class="w">                                </span><span class="bp">self</span><span class="p">.</span><span class="n">operand_from_scalar</span><span class="p">(</span><span class="w"></span>
<span class="w">                                    </span><span class="n">two</span><span class="p">,</span><span class="w"> </span><span class="n">substs</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="n">expect_ty</span><span class="p">(),</span><span class="w"> </span><span class="n">source_info</span><span class="p">.</span><span class="n">span</span><span class="w"></span>
<span class="w">                                    </span><span class="p">),</span><span class="w"></span>
<span class="w">                            </span><span class="p">],</span><span class="w"></span>
<span class="w">                            </span><span class="p">);</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
<span class="w">                </span><span class="p">},</span><span class="w"></span>
<span class="w">                </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="w">            </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="167197661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167197661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167197661">(Jun 03 2019 at 14:51)</a>:</h4>
<p>great, I'm gonna run tests</p>



<a name="167198117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198117">(Jun 03 2019 at 14:56)</a>:</h4>
<p><code>try_read_immediate</code> is private</p>



<a name="167198121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198121">(Jun 03 2019 at 14:56)</a>:</h4>
<p>should I make it public?</p>



<a name="167198126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198126">(Jun 03 2019 at 14:56)</a>:</h4>
<p>jop</p>



<a name="167198129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198129">(Jun 03 2019 at 14:56)</a>:</h4>
<p>crate wide only please</p>



<a name="167198146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198146">(Jun 03 2019 at 14:56)</a>:</h4>
<p>crate wide?</p>



<a name="167198166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198166">(Jun 03 2019 at 14:57)</a>:</h4>
<p><code>pub(crate)</code></p>



<a name="167198173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198173">(Jun 03 2019 at 14:57)</a>:</h4>
<p>oh</p>



<a name="167198175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167198175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167198175">(Jun 03 2019 at 14:57)</a>:</h4>
<p>sure</p>



<a name="167199048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167199048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167199048">(Jun 03 2019 at 15:07)</a>:</h4>
<p>I'm not using the <code>PlaceTy</code> in <code>replace_with_const</code>, is that ok?</p>



<a name="167199172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167199172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167199172">(Jun 03 2019 at 15:08)</a>:</h4>
<p>Yeah, I added that in <a href="https://github.com/rust-lang/rust/commit/499d1178181a428dccac3d24a9314f68c3f1cc58" target="_blank" title="https://github.com/rust-lang/rust/commit/499d1178181a428dccac3d24a9314f68c3f1cc58">499d1178181a428dccac3d24a9314f68c3f1cc58</a></p>



<a name="167199183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167199183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167199183">(Jun 03 2019 at 15:08)</a>:</h4>
<p>But if you don't need it, you can just remove it</p>



<a name="167202081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167202081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167202081">(Jun 03 2019 at 15:34)</a>:</h4>
<p>This is taking ages. I've never built rust on this machine hahah</p>



<a name="167202202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167202202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167202202">(Jun 03 2019 at 15:35)</a>:</h4>
<p>For most tests, you can do <code>./x.py test --stage 1 -i src/test/{test-dir}</code></p>



<a name="167202278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167202278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167202278">(Jun 03 2019 at 15:36)</a>:</h4>
<p>And for building just the compiler <code>./x.py build --stage 1 -i src/libstd</code></p>



<a name="167202308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167202308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167202308">(Jun 03 2019 at 15:36)</a>:</h4>
<blockquote>
<p>For most tests, you can do <code>./x.py test --stage 1 -i src/test/{test-dir}</code></p>
</blockquote>
<p>yeah I'm doing this</p>



<a name="167202312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167202312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167202312">(Jun 03 2019 at 15:36)</a>:</h4>
<p>ty</p>



<a name="167208494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167208494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167208494">(Jun 03 2019 at 16:42)</a>:</h4>
<p>ok we're ready</p>



<a name="167219825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167219825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167219825">(Jun 03 2019 at 18:53)</a>:</h4>
<p>the same test failed i think</p>



<a name="167220179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167220179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167220179">(Jun 03 2019 at 18:57)</a>:</h4>
<p>I'll fix the formatting issues just before rebasing</p>



<a name="167220877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167220877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167220877">(Jun 03 2019 at 19:05)</a>:</h4>
<p><span class="user-mention" data-user-id="132916">@Christian Poveda</span> I think the tests just need to be updated actually.</p>



<a name="167220885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167220885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167220885">(Jun 03 2019 at 19:05)</a>:</h4>
<p>They're failing because your patch is working now!</p>



<a name="167221189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167221189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167221189">(Jun 03 2019 at 19:08)</a>:</h4>
<p>Oh yea, _3 and _4 have the actual value</p>



<a name="167221229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167221229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167221229">(Jun 03 2019 at 19:09)</a>:</h4>
<p>shouldnt that pointer change from run to run?</p>



<a name="167221408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167221408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167221408">(Jun 03 2019 at 19:11)</a>:</h4>
<p>In <code>mir-opt/const_prop/const_prop_fails_gracefully.rs</code>?</p>



<a name="167221415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167221415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167221415">(Jun 03 2019 at 19:11)</a>:</h4>
<p>Yeah, I'm not sure about that</p>



<a name="167221436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167221436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167221436">(Jun 03 2019 at 19:11)</a>:</h4>
<p>That's a question for <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="167221455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167221455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167221455">(Jun 03 2019 at 19:11)</a>:</h4>
<p><code> mir-opt/const_prop/indirect.rs</code> Just needs to be updated though. The new behavior is correct.</p>



<a name="167227240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167227240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167227240">(Jun 03 2019 at 20:18)</a>:</h4>
<p>when Oli answers I'll upload both tests</p>



<a name="167227624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167227624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167227624">(Jun 03 2019 at 20:22)</a>:</h4>
<p>Sounds good</p>



<a name="167227768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167227768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167227768">(Jun 03 2019 at 20:24)</a>:</h4>
<p>We'll probably need to rewrite the <code>const_prop_fails_gracefully</code> test because the point of the test it to make sure the compiler doesn't ICE when it can't const prop stuff and you've implemented support for the thing it previously couldn't const prop.</p>
<p>However, your question about the pointer leaking into the MIR should still be answered and we should have a test around whatever the correct behavior there is as well.</p>



<a name="167240291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167240291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167240291">(Jun 03 2019 at 23:02)</a>:</h4>
<p><a href="http://indirect.rs" target="_blank" title="http://indirect.rs">indirect.rs</a> just needs updating, I agree</p>



<a name="167240331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167240331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167240331">(Jun 03 2019 at 23:03)</a>:</h4>
<p><code>const_prop_fails_gracefully</code> is pretty cool, since it actually shows that we don't propagate <code>_1 = move _2 as usize (Misc);</code>, because <code>_2</code> is a pointer which is not a valid <code>usize</code> at compile-time</p>



<a name="167240401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167240401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167240401">(Jun 03 2019 at 23:04)</a>:</h4>
<p>we won't ever const prop that, so the test still properly excercises what it is supposed to</p>



<a name="167240472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167240472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167240472">(Jun 03 2019 at 23:05)</a>:</h4>
<p>The <code>AllocId</code> showing up in MIR is a little funky, but ok. We should probably record all <code>AllocId</code>s printed during MIR printing and print their memory, too, but that's a future thing to do (open an issue about it?)</p>



<a name="167246392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167246392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167246392">(Jun 04 2019 at 00:53)</a>:</h4>
<p>But then should i change the test and hide the <code>AllocId</code>s? or should I leave them explicitly as in</p>
<div class="codehilite"><pre><span></span><span class="p">[</span><span class="mi">01</span>:<span class="mi">09</span>:<span class="mi">11</span><span class="p">]</span><span class="w">         </span><span class="n">_4</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">Scalar</span><span class="p">(</span><span class="n">AllocId</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="mh">0x0</span><span class="p">)</span><span class="w"> </span>: <span class="kp">&amp;</span><span class="kt">i32</span><span class="p">;</span><span class="w"></span>
<span class="p">[</span><span class="mi">01</span>:<span class="mi">09</span>:<span class="mi">11</span><span class="p">]</span><span class="w">         </span><span class="n">_3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">Scalar</span><span class="p">(</span><span class="n">AllocId</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="mh">0x0</span><span class="p">)</span><span class="w"> </span>: <span class="kp">&amp;</span><span class="kt">i32</span><span class="p">;</span><span class="w"></span>
<span class="p">[</span><span class="mi">01</span>:<span class="mi">09</span>:<span class="mi">11</span><span class="p">]</span><span class="w">         </span><span class="n">_2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">Scalar</span><span class="p">(</span><span class="n">AllocId</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="mh">0x0</span><span class="p">)</span><span class="w"> </span>: <span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">i32</span><span class="p">;</span><span class="w"></span>
</pre></div>



<a name="167246566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167246566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167246566">(Jun 04 2019 at 00:57)</a>:</h4>
<p>Leave them in I think</p>



<a name="167246722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167246722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167246722">(Jun 04 2019 at 01:00)</a>:</h4>
<p>sure, I'll fix that and commit</p>



<a name="167246837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167246837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167246837">(Jun 04 2019 at 01:03)</a>:</h4>
<p>I'm testing to avoid wasting CI :P</p>



<a name="167247049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167247049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167247049">(Jun 04 2019 at 01:08)</a>:</h4>
<p>The infra team thanks you <span aria-label="bow" class="emoji emoji-1f647" role="img" title="bow">:bow:</span></p>



<a name="167247539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167247539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167247539">(Jun 04 2019 at 01:18)</a>:</h4>
<p>Well its good to keep the pc exercising :P</p>



<a name="167247619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167247619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167247619">(Jun 04 2019 at 01:20)</a>:</h4>
<p>idk what to do with vim identation, I'll think I'll have to fix the identation manually</p>



<a name="167248056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167248056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167248056">(Jun 04 2019 at 01:30)</a>:</h4>
<blockquote>
<p>I'm testing to avoid wasting CI :P</p>
</blockquote>
<p><span class="user-mention" data-user-id="132916">@Christian Poveda</span> I'd much rather you save your own time because human time is much more precious than CI time. <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="167248076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167248076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167248076">(Jun 04 2019 at 01:31)</a>:</h4>
<p>oh well if you insist</p>



<a name="167256441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20indirects%20on%20const-prop/near/167256441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20indirects.20on.20const-prop.html#167256441">(Jun 04 2019 at 04:52)</a>:</h4>
<p>Ok it is done, going to rebase</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>